﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;

namespace DAL
{
    class ContextDBInitializer : DropCreateDatabaseAlways<ShopDBContext>
    {
        protected override void Seed(ShopDBContext context)
        {
            ProductCategory fish = new ProductCategory { Name = "Fish" };
            ProductCategory meet = new ProductCategory { Name = "Meet" };
            ProductCategory beer = new ProductCategory { Name = "Beer" };

            Product perch = new Product { Name = "Perch", Price = 51.50, ProductCategory = fish, ImageURL = "http://www.maine.gov/ifw/fishing/species/identification/images/yellowperch.jpg" };
            Product crucian = new Product { Name = "Crucian", Price = 34.00, ProductCategory = fish, ImageURL = "http://www.crucians.org/images/091111/b_martin_bowlers_crucians.jpg" };
            Product salmon = new Product { Name = "Salmon", Price = 240.70, ProductCategory = fish, ImageURL = "http://graphics8.nytimes.com/images/2013/08/11/magazine/11eat1/11eat1-superJumbo-v2.jpg" };

            Product pork = new Product { Name = "Pork", Price = 105, ProductCategory = meet, ImageURL = "http://ecofriendly.com/wp-content/uploads/2014/07/porkchops.jpg" };
            Product beef = new Product { Name = "Beef", Price = 90, ProductCategory = meet, ImageURL = "http://images.wisegeek.com/raw-beef-with-garnish.jpg" };
            Product horsemeat = new Product { Name = "Horsemeet", Price = 70, ProductCategory = meet, ImageURL = "https://c1.staticflickr.com/5/4139/4921532406_9c6df979b9_b.jpg" };

            Product baltykaSoft = new Product { Name = "Baltyka Soft", Price = 11.70, ProductCategory = beer, ImageURL = "http://www.produktoff.com/static/upload/goods/52/40752_original.jpg", Description = "Вкусненькое" };

            context.ProductCategories.AddRange(new[] { fish, meet, beer });
            context.Products.AddRange(new[] { perch, crucian, salmon, pork, beef, horsemeat, baltykaSoft });

            context.SaveChanges();
        }
    }
}
